home *** CD-ROM | disk | FTP | other *** search
/ Developer Helper 1: Phil & Dave's Excellent CD / Excellent CD HFS.raw / Utilities / ResEdit / Examples / PExamples / Source / GNRLLDEF.p next >
Text File  |  2022-08-05  |  2KB  |  95 lines

  1. {
  2. COPYRIGHT (C) 1984-1989 Apple Computer,Inc.
  3. All rights reserved
  4. }
  5. { General LDEF proc }
  6.  
  7. UNIT GnrlLDEF;
  8.  
  9. INTERFACE
  10.  
  11. USES MemTypes, QuickDraw, OSIntf, ToolIntf, PackIntf, ResEd;
  12.  
  13. PROCEDURE DrawCell(Message: INTEGER; lSelect: BOOLEAN; lRect: Rect; lCell: Point; lDataOffset,
  14.                                      lDataLen: INTEGER; lHandle: ListHandle);
  15.  
  16. IMPLEMENTATION
  17.  
  18.     {$R-}
  19.  
  20. PROCEDURE DrawCell(Message: INTEGER; lSelect: BOOLEAN; lRect: Rect; lCell: Point; lDataOffset,
  21.                                      lDataLen: INTEGER; lHandle: ListHandle);
  22.  
  23.     VAR
  24.         h: Handle;
  25.         t: ResType;
  26.         id: INTEGER;
  27.         st: Str255;
  28.         FInfo: FontInfo;
  29.  
  30.     FUNCTION GnrlFetch: Handle;
  31.  
  32.         VAR
  33.             id: INTEGER;    { Id is stored in the list - could be any type. }
  34.  
  35.         BEGIN
  36.         IF lDataLen > sizeof(id) THEN lDataLen := sizeof(id);    { Make sure that the length is ok. }
  37.         { Get the id from the list. }
  38.         BlockMove(Ptr(ord4(@lHandle^^.cells^^) + lDataOffset), @id, sizeof(id));
  39.         SetResLoad(FALSE); { Since all we want is the resinfo }
  40.         GnrlFetch := Get1Res(PickHandle(lHandle^^.refCon)^^.rType, id);
  41.         SetResLoad(TRUE);    { Always leave this set to true. }
  42.         END;
  43.  
  44.     PROCEDURE DoHilite;
  45.  
  46.         CONST
  47.             HiliteMode = $938;
  48.             theHiliteBit = 31;
  49.  
  50.         TYPE
  51.             longintPtr = ^longint;
  52.  
  53.         BEGIN
  54.         BCLR(longintPtr(HiliteMode)^, theHiliteBit);    { Use the proper hilighting for color. }
  55.         InvertRect(lRect);                                                        { Select the rectangle. }
  56.         END;
  57.  
  58.     BEGIN    { DrawCell }
  59.     CASE Message OF
  60.         lInitMsg:
  61.             BEGIN    { Set the proper indent distance. }
  62.             GetFontInfo(FInfo);
  63.             WITH FInfo, lHandle^^.indent DO
  64.                 BEGIN
  65.                 h := widmax DIV 3;
  66.                 v := ascent;
  67.                 END;
  68.             END;
  69.  
  70.         lDrawMsg:
  71.             IF lDataLen <> 0 THEN
  72.                 BEGIN
  73.                 h := GnrlFetch;                        { Get the resource. }
  74.                 IF h <> NIL THEN                    { If we got the resource. }
  75.                     BEGIN                                        { Build the string for this resource. }
  76.                     GetResInfo(h, id, t, st);
  77.                     TypeToString(t, st);
  78.                     SetETitle(h, st);                { Concatenate the id and the name of the resource. }
  79.                     WITH lRect, lHandle^^.indent DO     { Position the pen. }
  80.                         MoveTo(left + h, top + v);
  81.                     EraseRect(lRect);
  82.                     DrawString(st);
  83.                     IF lSelect THEN                    { Hilight if necessary. }
  84.                         DoHilite;
  85.                     END;
  86.                 END;
  87.  
  88.         lHiliteMsg: DoHilite;
  89.  
  90.         lCloseMsg: { nothing } ;
  91.         END;
  92.     END;
  93.  
  94. END.
  95.